package com.xiaodu.acer.phoneplay.presenter;

import com.xiaodu.acer.phoneplay.bean.CategoryBean;
import com.xiaodu.acer.phoneplay.common.rx.RxHttpReponseCompat;
import com.xiaodu.acer.phoneplay.common.rx.subscriber.ProgressSubcriber;
import com.xiaodu.acer.phoneplay.presenter.contract.CategoryContract;
import com.xiaodu.acer.phoneplay.ui.base.BasePresenter;

import java.util.List;

import javax.inject.Inject;


/**
 * @author 小杜
 *         邮箱:m15701207383@163.com
 * @version V1.0
 * @Description: ${TODO}(用一句话描述该文件做什么)
 * @date 2018/1/12 16:00
 */

public class CateogryPresenter extends BasePresenter<CategoryContract.Model, CategoryContract.View> {

    @Inject
    public CateogryPresenter(CategoryContract.Model model, CategoryContract.View view) {
        super(model, view);
    }

    public void getAllCategory() {
        mModel.getCategories()
                .compose( RxHttpReponseCompat.<List<CategoryBean>>compatResult())
                .subscribe(new ProgressSubcriber<List<CategoryBean>>(mContext, mView) {
                    @Override
                    public void onNext(List<CategoryBean> categoryBeans) {
                        mView.showData(categoryBeans);
                    }
                });
    }

}
